import { DomEditor } from '@wangeditor/editor'

// export const reply = {
//   type: 'reply',
//   id: 1,
//   userName: '张三',
//   time: '2022/11/7 18:21:06',
//   content: '测试回复内容',
//   children: [{ text: '' }] // void 元素必须有一个 children ，其中只有一个空字符串，重要！！！
// }

export function withReply(editor) {
  const { isInline, isVoid } = editor
  const newEditor = editor

  newEditor.isInline = elem => {
    const type = DomEditor.getNodeType(elem)
    if (type === 'reply') return false
    return isInline(elem)
  }

  newEditor.isVoid = elem => {
    const type = DomEditor.getNodeType(elem)
    if (type === 'reply') return true
    return isVoid(elem)
  }

  return newEditor
}
